<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="img/mi.jpg">
<title>微信运动(小米运动修改器)</title>
<link rel="stylesheet" href="layui/css/layui.css">
<link rel="stylesheet" href="css/login.css">
<link id="layuicss-laydate" rel="stylesheet" href="layui/css/modules/laydate/default/laydate%EF%B9%96v=5.3.1.css" media="all">
<link id="layuicss-layer" rel="stylesheet" href="layui/css/modules/layer/default/layer%EF%B9%96v=3.5.1.css" media="all">
<link id="layuicss-skincodecss" rel="stylesheet" href="layui/css/modules/code%EF%B9%96v=2.css" media="all">
</head>
<body>
<!-- 粒子背景 -->
<div id="particles-js">
  <canvas class="particles-js-canvas-el" width="1920" height="1080" style="width: 100%; height: 100%;"></canvas>
</div>
<!-- 登录表单 -->
<form class="layui-form login-form layui-panel" autocomplete="off" action="127.0.0.1:8712/begin">
  <h1 class="login-title"> <img style="height: 30px" src="img/mi.jpg" alt="logo"> <span>小米运动步数修改器</span> </h1>
  <!-- 手机号 -->
  <div class="layui-form-item"> <i class="layui-icon layui-icon-username"></i>
    <input type="text" name="code" placeholder="请输入手机号" class="layui-input" lay-verify="required|phone" lay-reqtext="请输入手机号">
  </div>
  <!-- 密码 -->
  <div class="layui-form-item"> <i class="layui-icon layui-icon-password"></i>
    <input type="password" name="pwd" placeholder="请输入密码" class="layui-input" lay-verify="required" lay-reqtext="请输入密码">
  </div>
  <!-- 步数 -->
  <div class="layui-form-item"> <i class="layui-icon layui-icon-login-wechat"></i>
    <input type="text" name="step" placeholder="请输入步数" class="layui-input" lay-verify="required|number|step" lay-reqtext="请输入步数">
     步数1-98000区间</div>
  <div class="layui-form-item">
    <button class="layui-btn layui-btn-normal layui-btn-fluid" id="submit" type="button" lay-submit="" lay-filter="login"> 开始刷 </button>
  </div>
</form>
<script src="layui/layui.js"></script> 
<script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script src="js/particles.js"></script> 
<script>
            layui.use(["form"], function () {
                const form = layui.form;
				form.verify({
					step: function(value, item){ //value：表单的值、item：表单的DOM对象
					if(value > 98800){
					  return '步数最高98800！';
					}
					if(value < 1){
					  return '步数必须大于0，且只可变多不可以变少！';
					}
					}
				});
                //监听提交
                form.on("submit(login)", function (data) {
					$("#submit").attr("disabled","true"); //设置变灰按钮
					var formData = data.field
						$.ajax({
							type : 'get',
							dataType: "json",
							url : 'https://mi.api.comon.ltd/begin',
							// url : 'http://127.0.0.1:8712/begin',
							data : formData,
							success : function(close) {
								if(close == null) {
									layer.msg("账号或者密码错误");
								}else{
									console.log(close)
									layer.msg(close);
								}
							},
							error : function(){
								console.log("异常！请联系QQ:1792268267")
								layer.msg("异常！");
							}
						})
					setTimeout("$('#submit').removeAttr('disabled')",3000); 
                });
            });
            //按下回车登录
            $("body").on("keyup", (e) => {
                if (e.which === 13) {
                    $("#submit").trigger("click");
                }
            });
        </script>
</body>
</html>